package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.beat.lib.core.BeatSoundType;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class TimbreAdapter extends StkProviderMultiAdapter<BeatSoundType> {

    public TimbreAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(82));
        addItemProvider(new TimBreProvider());
    }

    private int selPosition;

    public int getSelPosition() {
        return selPosition;
    }

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
    }

    private class TimBreProvider extends BaseItemProvider<BeatSoundType> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_timbre;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, BeatSoundType bean) {
            baseViewHolder.setText(R.id.tvTimbreItemText, bean.getName());
            if (selPosition == baseViewHolder.getBindingAdapterPosition()) {
                baseViewHolder.setTextColor(R.id.tvTimbreItemText, Color.parseColor("#FFFFFF"));
                baseViewHolder.setImageResource(R.id.ivTimbreItemSel, R.drawable.shape_note_sel);
            } else {
                baseViewHolder.setTextColor(R.id.tvTimbreItemText, Color.parseColor("#313131"));
                baseViewHolder.setImageResource(R.id.ivTimbreItemSel, R.drawable.shape_note_not_sel);
            }
        }

    }

}
